import wettkampf.*

class BootStrap {

	def authenticateService

     def init = { servletContext ->
		if (!Rolle.get(1)) {
			def r = new Rolle(authority: 'ROLE_ADMIN', description: 'Administrator')
			def n = new Nutzer(username: 'admin', userRealName: 'Administrator', passwd: authenticateService.passwordEncoder("password"), enabled: true, email: 'josch13@gmx.net')
			n.addToAuthorities(r)
			r.addToPeople(n)
			n.save()
			r.save()
			
			def r2 = new Rolle(authority: 'ROLE_USER', description: 'Userrolle')
			def n2 = new Nutzer(username: 'user1', userRealName: 'Nutzer', passwd: authenticateService.passwordEncoder("password"), enabled: true, email: 'jluelsdorf@gmail.com')
			n2.addToAuthorities(r2)
			r2.addToPeople(n2)
			n2.save()
			r2.save()
			
			new Photo(filename: '20.jpg', uploadedBy: n).save()
			new Photo(filename: '30.jpg', uploadedBy: n).save()
			new Photo(filename: '45.jpg', uploadedBy: n).save()
			new Photo(filename: '51.jpg', uploadedBy: n).save()
		}
     }
     def destroy = {
     }
} 